package com.sweetguy.entity;

import com.mybatisflex.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 *  实体类。
 *
 * @author SweetGuy
 * @since 2024-12-22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "seckill_detail", schema = "ml_sms")
public class SeckillDetail implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键，自增ID
     */
    @Id(keyType = KeyType.Auto)
    private Long id;

    /**
     * 秒杀活动ID，秒杀表外键
     */
    private Long fkSeckillId;

    /**
     * 课程ID，秒杀表外键
     */
    private Long fkCourseId;

    /**
     * 课程标题
     */
    private String courseTitle;

    /**
     * 课程封面图片链接
     */
    private String courseCover;

    /**
     * 课程单价
     */
    private Double coursePrice;

    /**
     * 秒杀价格
     */
    private Double skPrice;

    /**
     * 秒杀数量
     */
    private Integer skCount;

    /**
     * 描述
     */
    private String info;

    /**
     * 数据版本，非空，默认值为0
     */
    @Column(version = true)
    private Long version;

    /**
     * 逻辑删除标记，非空，默认值为0表示未删除，1表示已删除
     */
    @Column(isLogicDelete = true)
    private Integer deleted;

    /**
     * 创建时间，非空，默认为当前时间
     */
    private LocalDateTime created;

    /**
     * 更新时间，非空，默认为当前时间，记录更新时自动修改
     */
    private LocalDateTime updated;

    //秒杀明细[1] : 秒杀[1]
    @RelationOneToOne(selfField = "fkSeckillId", targetField = "id")
    private Seckill seckill;

    //秒杀明细[1] : 课程[1]
    @RelationOneToOne(selfField = "fkCourseId", targetField = "id")
    private Course course;
}
